package com.cinema.entity.movie;

import com.cinema.entity.hall.Hall;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * 场次实体类
 */
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class Schedule implements Serializable {
    private static final long serialVersionUID = 1L;
    private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");

    private String scheduleId;   // 场次ID
    private Movie movie;         // 关联影片
    private Hall hall;           // 放映厅
    private LocalDateTime showTime; // 放映时间
    private double price;        // 本场次票价
    private int soldTickets;     // 已售票数
    private int refundedTickets; // 退票数

    @Override
    public String toString() {
        return String.format(
                "场次ID：%s\n影片：%s\n放映厅：%s\n时间：%s\n票价：%.2f元\n已售：%d张\n退票：%d张",
                scheduleId, movie.getMovieName(), hall.getHallName(),
                showTime.format(FORMATTER), price, soldTickets, refundedTickets
        );
    }
}